<!--
 * @Author: HeAo
 * @Date: 2021-10-09 16:44:38
 * @LastEditTime: 2021-10-09 16:55:43
 * @LastEditors: HeAo
 * @Description: 
 * @FilePath: \web2103-2105\web2103code\3-2-Vue\day02\5-监听器.html
 * 别乱动！
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../js/vue.js"></script>
</head>

<body>
  <div id="app">
    用户名:<input type="text" v-model.lazy="username">
    密码:<input type="text" v-model.lazy="obj.password">
    <button @click="obj = {}">按钮</button>
  </div>
  <script>
    let vm = new Vue({
      el: '#app',
      data: {
        username: null,
        obj: {
          password: null
        }
      },
      watch: {
        username(newValue, oldValue) {
          console.log(newValue, oldValue);
        },
        // obj(newValue, oldValue) {
        //   console.log(newValue, oldValue);
        // },
        obj: {
          handler(newValue, oldValue) {
            // console.log(newValue, oldValue);
          },
          deep: true
        },
        'obj.password': {
          handler(newValue, oldValue) {
            console.log(newValue, oldValue);
          },
          deep: true
        }
      },
      methods: {},
      created() { }
    })
  </script>
</body>

</html>